﻿using LBCMS.EntityFrameWork;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LBCMS.BLL
{
    public class frameHelper
    {
        public string getData<T>(BLL.PredicateBuilder.queryCondition where, int page, int limit, OrderModelField order) where T : class
        {
            var con = PredicateBuilder.True<T>();
            if (where.and != null)
            {
                foreach (var item in where.and)
                {

                    var lambda = Helper.LambdaHelper.GetContains<T>(item.paraName, item.paraValue);
                    con = con.And(lambda);
                }
            }
            else
            {
                con = con.And(x => 1 == 1);
            }



            var retData = new DataCalss.retData<T>();

            //var data = db.E_Site.Where(con.Compile());

            var data = new EntityComm().GetListPaged<T>(page, limit, con, out int count, order);

            retData.count = count;
            retData.code = 0;
            retData.msg = "";
            retData.data = data;


            return Helper.JsonHelper.toJsonTime(retData);



        }

        public T formData<T>(T data) where T : class
        {
            

            return data;
        }

    }
}